package com.cmc.cloud.cmclink.doc.controller.admin.multimodaltransport;

import com.cmc.cloud.cmclink.doc.constants.UrlConstants;
import com.cmc.cloud.cmclink.doc.entity.BlnoCntrDO;
import com.cmc.cloud.cmclink.doc.entity.CalculateOperateLogDO;
import com.cmc.cloud.cmclink.doc.service.multimodaltransport.MultiLocalCostService;
import com.cmc.cloud.cmclink.doc.vo.multimodaltransport.localcost.*;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.operatelog.core.annotations.OperateLog;
import com.cmes.framework.operatelog.core.enums.OperateTypeEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @Description: 多联local cost计算
 * @Author: lzp
 * @Date: 2025/11/5 10:13
 */
@Tag(name = "管理后台-local cost")
@RestController
@Validated
@RequestMapping(UrlConstants.APPLICATION_URL + "/local/cost")
public class MultiLocalCostController {

    @Resource
    private MultiLocalCostService multiLocalCostService;


    @Operation(description = "multi local cost 提单信息查询")
    @PostMapping("/search")
    @OperateLog(name = "multi local cost 提单信息查询", type = OperateTypeEnum.GET)
    public CommonResult<List<MultiBlnoLocalCostRespVO>> getBlnoLocalCostInf(@Valid @RequestBody MultiBlnoLocalCostReqVO multiBlnoLocalCostReqVo) {
        return CommonResult.success(multiLocalCostService.getBlnoInfoLocalCost(multiBlnoLocalCostReqVo));
    }

    @Operation(summary = "创建Multi Local COST费用")
    @PostMapping("/create")
    @OperateLog(name = "multi local cost 新增", type = OperateTypeEnum.CREATE)
    //@PreAuthorize("@ss.hasPermission('doc:multi-local-cost:create')")
    public CommonResult<Void> createMultiLocalCost(@Valid @RequestBody MultiLocalCostCreateReqVO createReqVo) {
        multiLocalCostService.createMultiLocalCost(createReqVo);
        return CommonResult.success();
    }

    @Operation(summary = "更新Multi Local COST费用")
    @PostMapping("/update")
    @OperateLog(name = "multi local cost 修改", type = OperateTypeEnum.UPDATE)
    //@PreAuthorize("@ss.hasPermission('doc:multi-local-cost:update')")
    public CommonResult<Void> updateMultiLocalCost(@Valid @RequestBody MultiLocalCostUpdateReqVO updateReqVo) {
        multiLocalCostService.updateMultiLocalCost(updateReqVo);
        return CommonResult.success();
    }

    @Operation(summary = "删除Multi Local COST费用")
    @PostMapping("/delete/{id}")
    @Parameter(name = "id", description = "编号", required = true)
    @OperateLog(name = "multi local cost 删除", type = OperateTypeEnum.DELETE)
    //@PreAuthorize("@ss.hasPermission('doc:multi-local-cost:delete')")
    public CommonResult<Void> deleteMultiLocalCost(@PathVariable("id") Long id) {
        multiLocalCostService.deleteMultiLocalCost(id);
        return CommonResult.success();
    }

    @Operation(summary = "获得Multi Local COST费用")
    @GetMapping("/get/{blnoId}/{imExType}")
    @Parameters({
            @Parameter(name = "blnoId", description = "提单ID", required = true, example = "1024"),
            @Parameter(name = "imExType", description = "进出口类型", required = true, example = "1024")
    })
    @OperateLog(name = "multi local cost 查询", type = OperateTypeEnum.GET)
    //@PreAuthorize("@ss.hasPermission('doc:multi-local-cost:query')")
    public CommonResult<List<MultiLocalCostRespVO>> getMultiLocalCost(@PathVariable("blnoId") Long blnoId, @PathVariable("imExType") String imExType) {
        return CommonResult.success(multiLocalCostService.getMultiLocalCost(blnoId, imExType));
    }

    @Operation(summary = "获得Multi Local COST Detail费用")
    @GetMapping("/get/detail/{blnoId}/{imExType}")
    @Parameters({
            @Parameter(name = "blnoId", description = "提单ID", required = true, example = "1024"),
            @Parameter(name = "imExType", description = "进出口类型", required = true, example = "1024")
    })
    @OperateLog(name = "multi local cost detail查询", type = OperateTypeEnum.GET)
    //@PreAuthorize("@ss.hasPermission('doc:multi-local-cost:query')")
    public CommonResult<List<MultiLocalCostDetailRespVO>> getMultiLocalCostDetail(@PathVariable("blnoId") Long blnoId, @PathVariable("imExType") String imExType) {
        return CommonResult.success(multiLocalCostService.getMultiLocalCostDetail(blnoId, imExType));
    }

    @Operation(summary = "查询multi local cost log 信息")
    @GetMapping("/log/{blNo}/{imExType}")
    @OperateLog(name = "multi local cost log 信息", type = OperateTypeEnum.GET)
    public CommonResult<CalculateOperateLogDO> getCalculateLogInfo(@PathVariable("blNo") String blNo, @PathVariable("imExType") String imExType) {
        return CommonResult.success(multiLocalCostService.getMultiCalculateLogInfo(blNo, imExType));
    }

    @Operation(summary = "查询箱信息")
    @GetMapping("/cntr/{blId}")
    @OperateLog(name = "multi local cost箱信息查询", type = OperateTypeEnum.GET)
    public CommonResult<List<BlnoCntrDO>> getBlNoCntrInfo(@PathVariable("blId") Long blId) {
        return CommonResult.success(multiLocalCostService.getBlNoCntrInfo(blId));
    }

    @Operation(summary = "多联成本计算")
    @PostMapping("/calcutlate")
    @OperateLog(name = "multi local cost 计算")
    public CommonResult<List<MultiBlnoLocalCostResultVO>> calcutlate(@Valid @RequestBody MultiBlnoCalcutlatReqVO multiBlnoCalcutlatReqVo) {

        return null;
    }
}
